
package TransportesMarroquin;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;


public class Error {
    
         
         static Statement instruccion = null;
         static Connection conexion = null; 
         static MysqlDataSource dataSource= new MysqlDataSource();
          
            public Error (){
        try {
      
        dataSource.setUser("root");
        dataSource.setPassword("");
        dataSource.setDatabaseName("practicasp8");
        dataSource.setServerName("localhost");
        conexion = (Connection) dataSource.getConnection();
        instruccion = (Statement) conexion.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(Error.class.getName()).log(Level.SEVERE, null, ex);
        }
            }
   public static void Mysql (String consulta){
        try {
            dataSource.setUser("root");
            dataSource.setPassword("");
            dataSource.setDatabaseName("practicasp8");
            dataSource.setServerName("localhost");
            conexion = (Connection) dataSource.getConnection();
            instruccion = (Statement) conexion.createStatement();
         
            instruccion.executeUpdate(consulta);
            
            conexion.close();
            instruccion.close();
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Error "+ex);
        }
  }
  
}
